#ifndef BUBBLESORT_H
#define BUBBLESORT_H

#include "sortbase.h"
#include <QEventLoop>
#include <QVariantAnimation>

class BubbleSort : public SortBase
{
    Q_OBJECT
public:
    explicit BubbleSort(QObject *parent = nullptr);

    // virtual function/interface for sort
    void sort(size_t num_of_elem, int interval) override;
    void stop() override;
    void draw(QPainter *painter, int width, int height) override;
    void skip() override;

private:
    QEventLoop loop;
    QVariantAnimation animation;
    int interval{1};

    size_t sortedRound{0};
    size_t currentIndex{0};
    bool swapFlag{false};
};

#endif // BUBBLESORT_H
